# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=osrframework
pkgver=840.e02a6e9
pkgrel=6
pkgdesc='A project focused on providing API and tools to perform more accurate online researches.'
groups=('blackarch' 'blackarch-recon' 'blackarch-social')
arch=('any')
url='https://github.com/i3visio/osrframework'
license=('AGPL3')
depends=('python' 'python-beautifulsoup4' 'python-requests' 'python-tweepy'
         'python-python-emailahoy3' 'python-networkx' 'python-decorator'
         'python-validate-email' 'python-tabulate' 'python-oauthlib'
         'python-python-whois' 'python-yaml' 'python-colorama'
         'python-cfscrape' 'python-pyexcel' 'python-pyexcel-text'
         'python-pyexcel-xls' 'python-pyexcel-xlsx' 'python-pyexcel-ods'
         'python-pyexcel-io')
makedepends=('git' 'python-setuptools' 'python-pip')
source=("git+https://github.com/i3visio/$pkgname.git"
        'setup.py.patch')
sha512sums=('SKIP'
            '394d1d5600e7984b707e2f5bfad0b2af73c09a13742ffad24aee057aa6345e691c9c9afbaf04d27b497de0b04367d633e735789488f3a4ff399c042aed7f1760')

pkgver() {
  cd $pkgname

  echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

prepare() {
  patch -p1 < setup.py.patch
}

build() {
  cd $pkgname

  python setup.py build
}

package() {
  cd $pkgname

  #PIP_CONFIG_FILE=/dev/null pip2 install --isolated --root="$pkgdir" \
  #  --ignore-installed --no-deps ./

  python setup.py install --root="$pkgdir" --prefix=/usr -O1 --skip-build

  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname/" *.md doc/*
  install -Dm 644 COPYING "$pkgdir/usr/share/licenses/$pkgname/COPYING"

  rm -rf *.md doc COPYING

  cd "$pkgdir/usr/bin"

  for i in * ; do
    mv "$i" `echo "$pkgdir/usr/bin/osr-$i" | sed 's/.py//'`
  done

  find "$pkgdir" -type f \( -iname '*.pyc' -or -iname '*.pyo' \) -exec rm {} \;
}

